home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / func / dlist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  1.7 KB  |  88 lines

  1. /*
  2.  * dlist.c -- routines for managing display lists
  3.  *
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include "ui.h"
  8. #include "display.h"
  9. #include "plist.h"
  10.  
  11. /* draw_dlist() -- draw a linked list of segments */
  12.  
  13. draw_dlist(win, phead)
  14. Window win;
  15. struct dlist *phead;
  16. {
  17.   struct dlist *pstore;
  18.   XGCValues gcval;
  19.   int i;
  20.   XPoint pt;
  21.  
  22.   gcval.foreground=standout;
  23.   XChangeGC(display, gc, GCForeground, &gcval);
  24.   for (pstore=phead; pstore!=NULL; pstore=pstore->next) 
  25.     if (pstore->flags!=NODRAW) {
  26.       for (i=0; i < pstore->len; i++) {
  27.     itod_pt(&pstore->points[i].pt, &pt);
  28.     XDrawPoint(display, win, gc, (int) pt.x,
  29.            (int) pt.y);
  30.       }
  31.     }
  32. }
  33.  
  34. /* ref_dlist() -- refresh the backing store underneath a dlist */
  35. ref_dlist(win, phead)
  36. Window win;
  37. struct dlist *phead;
  38. {
  39.   struct dlist *pstore;
  40.   XGCValues gcval;
  41.   XPoint pt;
  42.   int i;
  43.  
  44.   for (pstore=phead; pstore!=NULL; pstore=pstore->next) {
  45.     for (i=0; i < pstore->len; i++) {
  46.       gcval.foreground=pstore->points[i].val;
  47.       XChangeGC(display, gc, GCForeground, &gcval);
  48.       itod_pt(&pstore->points[i].pt, &pt);
  49.       XDrawPoint(display, win, gc, (int) pt.x,
  50.          (int) pt.y);
  51.     }
  52.   }
  53. }
  54.  
  55. /* draw_pvec() -- draw a single point buffer  */
  56. draw_pvec(xid, pbuf, len)
  57.      XID xid;
  58.      struct pval *pbuf;
  59.      int len;
  60. {
  61.   register int i;
  62.   XGCValues gcval;
  63.   XPoint pt;
  64.  
  65.   gcval.foreground=standout;
  66.   XChangeGC(display, gc, GCForeground, &gcval);
  67.   for (i=0; i < len; i++) {
  68.     itod_pt(&pbuf[i].pt,&pt);
  69.     XDrawPoint(display, xid, gc, pt.x, pt.y);
  70.   }
  71. }
  72.  
  73. struct dlist
  74. *dlist_new()
  75. {
  76.   struct dlist *dl;
  77.  
  78.   if ((dl=(struct dlist *) malloc(sizeof(struct dlist)))==NULL) {
  79.     perror("malloc");
  80.     exit(0);
  81.   }
  82.   dl->next=dl->prev=NULL;
  83.   dl->points=NULL;
  84.   dl->len=0;
  85.   dl->flags=0;
  86.   return dl;
  87. }
  88.